package net.zjitc.config;

import net.zjitc.Bean2;
import net.zjitc.BeanList;
import net.zjitc.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 1、MyBean里生成一个bean对象交由spring管理
 */
@Configuration
public class MyBean {

    //生成的bean对象的名字是什么？不是类类型，而是方法名
    //方法名作为bean对象的名称
    @Bean
    public Bean2 createBeanabc(){
        return new Bean2();
    }

    /**
     * 当有参数时，是从容器中找对应的类型的bean对象，拿到对象后传入形参即可
     * @param bean2
     * @return
     */
    @Bean
    public BeanList createBeanList(Bean2 bean2){

        BeanList beanList = new BeanList();
        beanList.setBean2(bean2);
        return beanList;
    }
}
